<script setup>
import {ref} from 'vue';
const num = ref('');
const result = ref('');

let n = parseInt(Math.random()*100) + 1;
console.log(n);
const guess = () => {
  if(num.value>n){
    result.value = '猜大了';
  }else if(num.value<n){
    result.value = '猜小了';
  }else{
    result.value = '恭喜您，猜对了';
  }
}
</script>

<template>
  <h1>猜数字练习</h1>
  <h3>1~100之间的随机整数</h3>
  <input type="text" v-model="num" placeholder="请输入你猜的数字">
  <button @click="guess">猜猜看呢</button>
  <h3>小提示:{{result}}</h3>
</template>

<style scoped>

</style>